// adapter/rest/BookResponse.java
package com.library.bookservice.adapter.rest;

import com.library.bookservice.domain.model.Book;
import java.time.LocalDate;

/**
 * 图书响应DTO
 */
public record BookResponse(
        Long id,
        String isbn,
        String title,
        String author,
        String genre,
        LocalDate publicationDate,
        boolean available,
        Integer totalCopies,
        Integer availableCopies
) {
    public static BookResponse from(Book book) {
        return new BookResponse(
                book.getId(),
                book.getIsbn(),
                book.getTitle(),
                book.getAuthor(),
                book.getGenre(),
                book.getPublicationDate(),
                book.isAvailable(),
                book.getTotalCopies(),
                book.getAvailableCopies()
        );
    }
}